using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace DAO
{
    class DataProvider
    {
        public static DataTable ExcuteQuery(string sql)
        {
            string connect = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=QuanLyThuVien.mdb";
            OleDbConnection con = new OleDbConnection (connect);//tao chuoi ket noi
            OleDbDataAdapter adt = new OleDbDataAdapter (sql ,con);//thuc thi cau truy van
            DataTable dt = new DataTable ();
            adt .Fill(dt);
            return dt;
        }
        public static void ExecutenonQuery(string sql)
        {
            string connect = "Provider=Microsoft.JET.OLEDB.4.0; Data Source = QuanLyThuVien.mdb";
            OleDbConnection con = new OleDbConnection(connect);// tao chuoi ket noi
            OleDbCommand cmd = new OleDbCommand(sql, con);
            con.Open();// mo ket noi
            cmd.ExecuteNonQuery();// thuc thi truy van
            con.Close();
            cmd.Dispose();
        }
    }
}
